directory   '<%= current_path %>'
environment '<%= fetch(:rack_env, fetch(:rails_env, "production")) %>'
daemonize false
quiet
pidfile '<%= fetch(:runit_puma_pid)%>'
state_path '<%= fetch(:runit_puma_state)%>'
stdout_redirect '<%= fetch(:runit_puma_log)%>', '<%= fetch(:runit_puma_log)%>', true

workers <%= fetch(:runit_puma_workers, 1) %>
threads <%= fetch(:runit_puma_threads_min, 0) %>, <%= fetch(:runit_puma_threads_max, 16) %>
bind "<%= host.fetch(:runit_puma_bind) or fetch(:runit_puma_bind) %>"

<% if fetch(:runit_puma_preload_app) %>
preload_app!
<% end %>

on_restart do
  puts 'Refreshing Gemfile'
  ENV["BUNDLE_GEMFILE"] = "<%= fetch(:bundle_gemfile, "#{current_path}/Gemfile") %>"
end

<% if fetch(:runit_puma_init_active_record) %>
on_worker_boot do
  ::ActiveSupport.on_load(:active_record) do
    ::ActiveRecord::Base.establish_connection
  end
end
<% end %>
<% unless fetch(:runit_puma_on_worker_boot, nil).nil? %>
on_worker_boot do
<%= fetch(:runit_puma_on_worker_boot) %>
end
<% end %>
